<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="js/mui.min.js"></script>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<script src="//g.alicdn.com/dingding/open-develop/1.6.9/dingtalk.js"></script>
		<script src="js/common.js" type="text/javascript" charset="utf-8"></script>

		<script type="text/javascript" charset="utf-8">
			$(function() {
				var id;
				

				dd.ready(function() {

					dd.runtime.permission.requestAuthCode({
						corpId: 'dingdd68e5ace8321d7a35c2f4657eb6378f', // 企业id
						onSuccess: function(info) {
							// 通过该免登授权码可以获取用户身份
							var json = new Object();
							json.authCode = info.code;
							
							$.ajax({
								url: route + 'login',
								//将获取到的code传到后台
								data: JSON.stringify(json),
								async: false,
								headers: {
									"Content-Type": "application/json;charset=UTF-8"
								},
								dataType: 'json', //服务器返回json格式数据
								type: 'post', //HTTP请求类型
								success: function(data) {
									//获取用户信息
									$(".head").attr('src', data.avatar);
									id = data.userId;
									//将获取到的数据渲染到页面上
									$(".name").text(data.name + " " + data.position);
									var parJson = new Object();
									parJson.userId = data.userId;
									$.ajax({
										url: route + 'investigation/findCodePath',
										//将获取到的userId传到后台
										data: JSON.stringify(parJson),
										async: false,
										headers: {
											"Content-Type": "application/json;charset=UTF-8"
										},
										dataType: 'json', //服务器返回json格式数据
										type: 'post', //HTTP请求类型
										success: function(data) {
											//获取二维码
											var c = data.data;
											if (data.code == 0) {
												c = c + "?t=" + new Date().getTime();
												//将二维码渲染到页面
												$("#scan").attr('src', c);
											}
											
											if(data.data==null||data.data=="error"||data.data==""){
												//判断如果没有二维码则将调查按钮变成不可点击
												c = c + "?t=" + new Date().getTime();
												$("#scan").attr('src', c);
												
												
											}else{
												$(".investigation").attr('disabled', "true");
												
											}
											
										},
										error: function(XMLHttpRequest, textStatus, errorThrown) {
											//alert(textStatus);
										}
									});
								},
								error: function(XMLHttpRequest, textStatus, errorThrown) {
									//alert(textStatus); 
								}
							});
						},
						onFail: function(err) {
							//alert(JSON.stringify(data));
						},

					});

				});

				$(".clock").click(function() {
					//点击刷新按钮跳转到主页实现刷新功能
					mui.openWindow({
						url: "./index.html"
					})
				});
				$(".investigation").click(function() {
					//点击疫情按钮跳转页面
					mui.openWindow({
						url: "./investigation.html"
					})
				})
				$(".img").click(function() {
					//点击历史图标跳转页面
					mui.openWindow({
						url: "./history.html"
					})
				})

				$(".sao").click(function() {
					dd.ready(function() {
						//调用手机扫码功能
						dd.biz.util.scan({
							type: 'all', // type 为 all、qrCode、barCode，默认是all。 
							onSuccess: function(data) {
								//扫码跳转到页面
								window.location.href = data.text;
							},
							onFail: function(err) {}
						})
					});

				})
			})
		</script>
		<style type="text/css">
			.top {
				width: 100%;

				background-color: #3396FB;


			}

			.head {

				border: 5px solid #fff;
				border-radius: 50%;

			}

			.name {
				margin-left: 20px;
				color: #FFFFFF;
				font-size: 24px;

			}

			.top-information {
				padding: 20px;
				display: flex;
				line-height: 70px;




			}

			.Video-body {
				width: 50%;

				z-index: 999999;
				padding-bottom: 5px;


			}

			.Video {
				display: flex;
				text-align: center;
			}

			.Video-body>img {
				width: 20px;
				height: 20px;
			}

			.head {
				width: 90px;
				height: 85px;
			}



			.Video-body1 {
				width: 50%;
				color: #FFFFFF;



			}

			.Fill {

				padding: 10px;
				padding-bottom: 0px !important;
			}

			.Fill-body {
				background-color: #FFFFFF;
				padding: 10px;
				border-radius: 5px;
			}

			.title {
				font-weight: 700;
				position: relative;
			}

			.Fill-btn {
				display: flex;
				text-align: center;
				padding: 10px;


			}

			.list {
				width: 50%;
				font-size: 18px;
			}

			.investigation {
				background-color: #8383D9;
				line-height: 30px;
				color: #FFFFFF;
				border-radius: 8px;
			}

			.clock {
				background-color: #48CEC7;
				
				color: #FFFFFF;
				border-radius: 8px;
				position: absolute;
				top: -5px;
				margin-left: 5px;
				
			}

			.code {
				border: 1px solid #FBFBFB;
				border-radius: 5px;



			}

			.code-body {
				padding: 8px;
			}

			.code>img {
				width: 100%;

			}

			.font {
				width: 100%;
				text-align: center;
				color: #808080;
				font-size: 13px;
			}

			.jobName {

				color: #FFFFFF;

			}
		</style>
	</head>
	<body>
		<div class="content">
			<div class="top">
				<!--头部-->
				<div class="top-information">
					<img src="./img/logo.jpg" class="head">
					<span class="name"></span>
					<div class="jobName"></div>
				</div>

				<div class="Video">
					<!-- 我的历史 -->
					<div class="Video-body img">
						<img src="img/lishi.png">

					</div>
					<!-- 扫一扫 -->
					<div class="Video-body sao">
						<img src="img/so.png">
					</div>


				</div>
				<div class="Video" style="padding-bottom: 10px;">
					<div class="Video-body1">
						<div>
							我的历史
						</div>

					</div>

					<div class="Video-body1">
						<div>
							扫一扫
						</div>
					</div>


				</div>
			</div>
			<!-- 中间部分 -->
			<div class="Fill">
				<div class="Fill-body">
					
					<div class="title">
						防疫信息填报
					</div>
					<div class="Fill-btn">
						<div class="list">
							<!-- 疫情填报按钮 -->
							<button type="primary" class="investigation">新冠肺炎防疫调查</button>
						</div>
						<div class="list">
						
						</div>
					</div>
				</div>
			</div>
			<!-- 二维码 -->
			<div class="Fill">
				<div class="Fill-body">
					<div class="title">
						我的健康码 <button type="primary" class="clock">刷新</button>
					</div>
					<div class="code-body">
						<div class="code">
							<img id="scan" src="">
						</div>
					</div>
				</div>
			</div>
		<!-- 	底部 -->
			<div class="font">
				金鹏控股集团<span style="color: red;">信息中心</span>提供技术支持
			</div>


		</div>
	</body>
</html>
